package com.koron.system.agent.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.bean.system.agent.po.AgentUserPo;
import com.koron.bean.system.agent.vo.AgentUserVo;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.system.agent.bean.query.AgentUserQuery;
import com.koron.system.agent.service.AgentUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 代理用户表(AgentUser)表控制层
 *
 * @author zhouj
 * @since 2021-11-23 17:45:40
 */
@Api(tags = "代理用户表(AgentUser)")
@RestController
@RequestMapping("/agentUser/")
public class AgentUserController {

    @Autowired
    private AgentUserService agentUserService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改代理用户表")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody AgentUserPo agentUser) {
        return Response.ok(agentUserService.insertOrUpdate(agentUser));
    }

    @ApiOperation(value = "新增代理用户表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody AgentUserPo agentUser) {
        return Response.ok(agentUserService.insert(agentUser));
    }

    @ApiOperation(value = "批量新增代理用户表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<AgentUserPo> agentUserList) {
        return Response.ok(agentUserService.insertBatch(agentUserList));
    }

    @ApiOperation(value = "根据id更新代理用户表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody AgentUserPo agentUser) {
        return Response.ok(agentUserService.update(agentUser));
    }

    @ApiOperation(value = "根据id删除代理用户表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(agentUserService.deleteById(id));
    }

    @ApiOperation(value = "根据id查询代理用户表")
    @GetMapping("queryById")
    public Response<AgentUserPo> queryById(String id) {
        return Response.ok(agentUserService.queryById(id));
    }

    @ApiOperation(value = "不分页查询代理用户表列表")
    @GetMapping("queryList")
    public Response<List<AgentUserPo>> queryList(AgentUserPo queryVo) {
        return Response.ok(agentUserService.queryList(queryVo));
    }

    @ApiOperation(value = "不分页查询代理用户表Vo列表")
    @GetMapping("queryVoList")
    public Response<List<AgentUserVo>> queryVoList(AgentUserQuery userQuery) {
        return Response.ok(agentUserService.queryVoList(userQuery));
    }

    @ApiOperation(value = "分页查询代理用户表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(AgentUserPo queryPo, PageQuery pageQuery) {
        return Response.ok(agentUserService.queryPageList(queryPo, pageQuery));
    }

}
